﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Baosight.ZNH.ZMCommon;
using Baosight.ZNH.ZMCommon.ChildWindows;
using Baosight.Platform.Core;

namespace Baosight.ZNH.ZMCP.UI.PopWindows
{
    public partial class QuitPlanItam : EFViewCmes
    {
        public QuitPlanItam()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CommitClick(object sender, RoutedEventArgs e)
        {
            TempButton = sender as Button;
            TempButton.IsEnabled = false;

            IList<EIRow> _list = this.grid.GetCheckedEIRows() == null ? new List<EIRow>() : this.grid.GetCheckedEIRows();

            if (_list.Count == 0)
            {
                base.OpenEFWindowAlert("请先选择一条生产计划", true);
            }
            EIInfo info = new EIInfo();
            info.Set(EIConstants.ServiceNameKey, "ZMCP12");
            info.Set(EIConstants.MethodNameKey, "quit");
            info.Set("fdKeyId", this.fdKeyId.Value);
            EIBlock block = info.AddBlock("result");
            block.SetColumns(this.grid.EIBlock.Columns);
            block.SetRows(this.grid.CheckedEIRows);
            base.Submit(info, DoCommitCompleted);
        }

        /// <summary>
        /// 取消按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CancelClick(object sender, RoutedEventArgs e)
        {
            CmesWindows _window = this.Parent as CmesWindows;
            _window.DialogResult = false;
            _window.Close();
        }
    }
}
